import { store as pinia } from '@/pinia';
import { usePageStore } from '@/pinia/modules/page';
import { usePageButtonStore } from '@/pinia/modules/pageButton';
import { usePageCompStore } from '@/pinia/modules/pageComp';
import { useDataFormStore } from '@/pinia/modules/dataForm';
import { useDataTableStore } from '@/pinia/modules/dataTable';
import { useDataFieldStore } from '@/pinia/modules/dataField';

const pageStore = usePageStore(pinia);
const pageButtonStore = usePageButtonStore(pinia);
const pageCompStore = usePageCompStore(pinia);
const dataFormStore = useDataFormStore(pinia);
const dataTableStore = useDataTableStore(pinia);
const dataFieldStore = useDataFieldStore(pinia);

export const getPage = (id, menuId) => {
  return pageStore.getById(id, menuId);
};

export const getPageButton = () => {
  return pageButtonStore.getList();
};

export const getPageComp = (id, menuId) => {
  return pageCompStore.getById(id, menuId);
};

export const getDataForm = (id) => {
  return dataFormStore.getById(id);
};

export const getDataTable = (id) => {
  return dataTableStore.getById(id);
};

export const getDataField = (id) => {
  return dataFieldStore.getById(id);
};

export const getDataFieldList = (id) => {
  return dataFieldStore.getByModelId(id);
};

export const clearPage = () => {
  return pageStore.clearData();
};

export const clearPageButton = () => {
  return pageButtonStore.clearData();
};

export const clearPageComp = () => {
  return pageCompStore.clearData();
};

export const clearDataForm = () => {
  return dataFormStore.clearData();
};

export const clearDataTable = () => {
  return dataTableStore.clearData();
};

export const clearDataField = () => {
  return dataFieldStore.clearData();
};

export const clearCache = () => {
  pageStore.clearData();
  pageButtonStore.clearData();
  pageCompStore.clearData();
  dataFormStore.clearData();
  dataTableStore.clearData();
  dataFieldStore.clearData();
};

export default {
  getPage,
  getPageButton,
  getPageComp,
  getDataForm,
  getDataTable,
  getDataField,
  getDataFieldList,
  clearPage,
  clearPageButton,
  clearPageComp,
  clearDataForm,
  clearDataTable,
  clearDataField,
  clearCache
}
